package com.syni.mdd.yhd.common.all.controller.api.push;

import com.alibaba.fastjson.JSON;
import com.syni.mdd.sjb.common.component.utils.common.annotations.EntranceCheck;
import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.sjb.common.component.utils.common.utils.RpcResponseVo;
import com.syni.mdd.yhd.common.all.constants.ResultMsg;
import com.syni.mdd.yhd.common.all.dto.requestDto.api.PushDto;
import com.syni.mdd.yhd.common.all.service.api.AuroraPushService;
import com.syni.mdd.yhd.common.all.utils.aurora.AuroraPushUtils;
import com.syni.mdd.sjb.common.component.utils.feign.dto.mddAll.apiAuroraPush.CommonPushDto;
import com.syni.mdd.sjb.common.component.utils.feign.service.mddAll.AuroraPushRestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @className ApiAuroraPushController
 * @description TOO
 * @Author cfx
 * @DATE 2019/7/17 9:06
 * @VERSION 1.0
 **/
@RestController
@RequestMapping("/ApiAuroraPush")
public class ApiAuroraPushRestApi implements AuroraPushRestService {
    protected static final Logger LOG = LoggerFactory.getLogger(AuroraPushUtils.class);


    @Autowired
    AuroraPushService auroraPushService;

    @PostMapping("/push")
    public Map<String,Object> push(@RequestBody PushDto pushDto){
            auroraPushService.pushNews(pushDto);
        return ResultMapHelper.success();
    }

    @PostMapping("/commonPush")
    public RpcResponseVo commonPush(@RequestBody CommonPushDto commonPushDto){
        auroraPushService.commonPushNews(commonPushDto);
        return RpcResponseVo.success(null, ResultMsg.HAND_SUCCESS);
    }

    @PostMapping("/commonCustomMessage")
    public RpcResponseVo commonCustomMessage(@RequestBody CommonPushDto commonPushDto){
        LOG.info("commonPushDto:{}", JSON.toJSONString(commonPushDto));
        auroraPushService.commonCustomMessage(commonPushDto);
        return RpcResponseVo.success(null, ResultMsg.HAND_SUCCESS);
    }

}
